package com.regent.central.bill.repository.mrp.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 采购单详情DTO
 *
 * @author 钟宝林
 * @String 2018-06-18 16:59
 **/
public class BillMaterialPurchaseDetailDTO implements Serializable {
    private static final long serialVersionUID = -2534811608889629781L;

    private String id;
    private String dateCreated;
    private String datePurchase;
    private String supplierId;
    private String bossUnitId;
    private String unitId;
    private String orderNo;
    private String expectDateEnd;
    private String creatorId;
    private String creatorName;
    private BigDecimal amountPay;
    private String remark;
    private Integer cancel;
    private PurchaseDTO purchase;
    private ArriveDTO arrive;
    private MaterialRemittanceDTO remittance;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(String dateCreated) {
        this.dateCreated = dateCreated;
    }

    public String getSupplierId() {
        return supplierId;
    }

    public String getDatePurchase() {
        return datePurchase;
    }

    public void setDatePurchase(String datePurchase) {
        this.datePurchase = datePurchase;
    }

    public void setSupplierId(String supplierId) {
        this.supplierId = supplierId;
    }

    public String getBossUnitId() {
        return bossUnitId;
    }

    public void setBossUnitId(String bossUnitId) {
        this.bossUnitId = bossUnitId;
    }

    public String getUnitId() {
        return unitId;
    }

    public void setUnitId(String unitId) {
        this.unitId = unitId;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getExpectDateEnd() {
        return expectDateEnd;
    }

    public void setExpectDateEnd(String expectDateEnd) {
        this.expectDateEnd = expectDateEnd;
    }

    public String getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(String creatorId) {
        this.creatorId = creatorId;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getCancel() {
        return cancel;
    }

    public void setCancel(Integer cancel) {
        this.cancel = cancel;
    }

    public PurchaseDTO getPurchase() {
        return purchase;
    }

    public void setPurchase(PurchaseDTO purchase) {
        this.purchase = purchase;
    }

    public ArriveDTO getArrive() {
        return arrive;
    }

    public void setArrive(ArriveDTO arrive) {
        this.arrive = arrive;
    }

    public MaterialRemittanceDTO getRemittance() {
        return remittance;
    }

    public void setRemittance(MaterialRemittanceDTO remittance) {
        this.remittance = remittance;
    }

    public BigDecimal getAmountPay() {
        return amountPay;
    }

    public void setAmountPay(BigDecimal amountPay) {
        this.amountPay = amountPay;
    }

    /**
     * 采购详情DTO
     */
    public static class PurchaseDTO {
        /**
         * 物料款数
         */
        private Integer quantityMaterials;
        /**
         * 采购金额总数
         */
        private BigDecimal amountTotal;
        /**
         * 采购详情列表
         */
        private List<MaterialPurchaseDTO> purchases = new ArrayList<>();

        public Integer getQuantityMaterials() {
            return quantityMaterials;
        }

        public void setQuantityMaterials(Integer quantityMaterials) {
            this.quantityMaterials = quantityMaterials;
        }

        public BigDecimal getAmountTotal() {
            return amountTotal;
        }

        public void setAmountTotal(BigDecimal amountTotal) {
            this.amountTotal = amountTotal;
        }

        public List<MaterialPurchaseDTO> getPurchases() {
            return purchases;
        }

        public void setPurchases(List<MaterialPurchaseDTO> purchases) {
            this.purchases = purchases;
        }
    }

    /**
     * 到料详情DTO
     */
    public static class ArriveDTO {
        /**
         * 已完成物料款数
         */
        private Integer completedMaterials;
        /**
         * 目标物料款数
         */
        private Integer targetMaterials;
        /**
         * 到料金额总数
         */
        private BigDecimal amountTotal;
        /**
         * 到料详情列表
         */
        private List<MaterialArriveDTO> arrives = new ArrayList<>();

        public Integer getCompletedMaterials() {
            return completedMaterials;
        }

        public void setCompletedMaterials(Integer completedMaterials) {
            this.completedMaterials = completedMaterials;
        }

        public Integer getTargetMaterials() {
            return targetMaterials;
        }

        public void setTargetMaterials(Integer targetMaterials) {
            this.targetMaterials = targetMaterials;
        }

        public BigDecimal getAmountTotal() {
            return amountTotal;
        }

        public void setAmountTotal(BigDecimal amountTotal) {
            this.amountTotal = amountTotal;
        }

        public List<MaterialArriveDTO> getArrives() {
            return arrives;
        }

        public void setArrives(List<MaterialArriveDTO> arrives) {
            this.arrives = arrives;
        }
    }

    /**
     * 流水详情DTO
     */
    public static class MaterialRemittanceDTO {
        /**
         * 本单应付(等于到料金额)
         */
        private BigDecimal amountTarget;
        /**
         * 实际付款
         */
        private BigDecimal amountActual;
        /**
         * 本单结欠=本单应付-实际付款
         */
        private BigDecimal amountRest;
        /**
         * 流水详情列表
         */
        private List<MaterialRemittanceDetailDTO> remittances = new ArrayList<>();

        public BigDecimal getAmountTarget() {
            return amountTarget;
        }

        public void setAmountTarget(BigDecimal amountTarget) {
            this.amountTarget = amountTarget;
        }

        public BigDecimal getAmountActual() {
            return amountActual;
        }

        public void setAmountActual(BigDecimal amountActual) {
            this.amountActual = amountActual;
        }

        public BigDecimal getAmountRest() {
            if (amountTarget != null && amountActual != null) {
                amountRest = amountTarget.subtract(amountActual);
                amountRest = amountRest.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : amountRest;
            }
            return amountRest;
        }

        public void setAmountRest(BigDecimal amountRest) {
            this.amountRest = amountRest;
        }

        public List<MaterialRemittanceDetailDTO> getRemittances() {
            return remittances;
        }

        public void setRemittances(List<MaterialRemittanceDetailDTO> remittances) {
            this.remittances = remittances;
        }
    }

}
